<?php

class ShopsController extends AppController {
    var $name = 'Shops';
    var $helpers = array('Html','Paginator','Ajax','Javascript','Form');
	var $components = array('Session');
    var $paginate = array('limit' => 10,
                          'order' => array('Name' => 'desc'));
	
	function index(){
    	$this->layout = "shop";
        $data = $this->paginate("Shop");
        $this->set("data",$data);
	}
	
	function shop_form($id = null){
    	  $this->layout = "home";
		  
		  $this->Shop->id = $id;
          $this->set('idata', $this->Shop->read());
		  
		  $this->loadModel('Shoptype');
		  $mang = $this->Shoptype->find('all');
		  $this->set('mang',$mang);
	}
	function add() {

			$name = $_REQUEST['name'];
			$sologan = $_REQUEST['sologan'];
			$shoptype = $_REQUEST['shoptype'];
			$status = $_REQUEST['status'];
	
			$this->Shop->create();
			$this->Shop->set('name', $name);
			$this->Shop->set('sologan', $sologan);
			$this->Shop->set('shoptype_id', $shoptype);
			$this->Shop->set('status', $status);
			$this->Shop->saveAll();

        $this->redirect(array("action" => "index", $this->Shop->id));
    }
	function edit($id = null) {
		if(!empty($id)){
			$name = $_REQUEST['name'];
			$sologan = $_REQUEST['sologan'];
			$shoptype = $_REQUEST['shoptype'];
			$status = $_REQUEST['status'];
			
			$this->Shop->id=$id;
			$this->Shop->set('name', $name);
			$this->Shop->set('sologan', $sologan);
			$this->Shop->set('shoptype_id', $shoptype);
			$this->Shop->set('status', $status);
			$this->Shop->updateAll();
		}
        $this->redirect(array("action" => "index", $id));
    }
	
	
}
?>